#include<bits/stdc++.h>
using namespace std;
namespace IO
{
	char buff[1<<21],*p1=buff,*p2=buff;
	char getch(){return p1==p2&&(p2=((p1=buff)+fread(buff,1,1<<21,stdin)),p1==p2)?EOF:*p1++;}
	template<typename T>void read(T &x){char CH=getch();int fl=1;x=0;while(CH>'9'||CH<'0'){if(CH=='-')fl=-1;CH=getch();}while(CH<='9'&&CH>='0'){x=x*10+CH-48;CH=getch();}x*=fl;}
	template<typename T>void read_s(T &x){x="";char CH=getch();while(!(CH>='a'&&CH<='z')&&!(CH>='A'&&CH<='Z'))CH=getch();while((CH>='a'&&CH<='z')||(CH>='A'&&CH<='Z')){x+=CH;CH=getch();}}
	template<typename T,typename ...Args>void read(T &x,Args& ...args){read(x);read(args...);}
	char obuf[1<<21],*p3=obuf;
	void putch(char CH) {if(p3-obuf<(1<<21))*p3++=CH;else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=CH;}
	char CH[100];
	template<typename T>void write(T x) {if(!x)return putch('0');if(x<0)putch('-'),x*=-1;int top=0;while(x)CH[++top]=x%10+48,x/=10;while(top)putch(CH[top]),top--;}
	template<typename T,typename ...Args>void write(T x,Args ...args) {write(x);putch(' ');write(args...);}
	void put(string s){for(int i=0;i<s.size();i++)putch(s[i]);}
	void flush(){fwrite(obuf,p3-obuf,1,stdout);}
}
using namespace IO;
int n,k,m;
int f[500005];
int find(int x){return f[x]==x?x:f[x]=find(f[x]);}
namespace Shiroha
{
	#define pii pair<int,int>
	#define fi first
	#define se second
	struct segt
	{
		pii val,val1;int tagp,taga;
	}t[500005<<2];
	#define ls (root<<1)
	#define rs (root<<1|1)
	#define mid (l+r>>1)
	inline void down(int root)
	{
		if(!t[root].tagp) return;
		t[ls].val.fi+=t[root].taga;t[rs].val.fi+=t[root].taga;
		t[ls].val1.fi+=t[root].taga;t[rs].val1.fi+=t[root].taga;
		t[ls].val.se=-(t[root].tagp-t[ls].val1.se+1);
		t[rs].val.se=-(t[root].tagp-t[rs].val1.se+1);
		t[ls].tagp=t[rs].tagp=t[root].tagp;
		t[ls].taga+=t[root].taga;t[rs].taga+=t[root].taga;
		t[root].tagp=t[root].taga=0;
	}
	void bld(int root=1,int l=1,int r=n)
	{
		if(l==r) return t[root].val={0,0},t[root].val1={0,l},void();
		bld(ls,l,mid);bld(rs,mid+1,r);
		t[root].val=max(t[ls].val,t[rs].val);
		t[root].val1=max(t[ls].val1,t[rs].val1);
	}
	void add(int x,int y,int p,int root=1,int l=1,int r=n)
	{
		if(l>=x&&r<=y)
		{
			++t[root].val.fi;++t[root].val1.fi;
			t[root].val.se=-(p-t[root].val1.se+1);
			t[root].tagp=p;++t[root].taga;
			return;
		}
		down(root);
		if(x<=mid) add(x,y,p,ls,l,mid);
		if(y>mid) add(x,y,p,rs,mid+1,r);
		t[root].val=max(t[ls].val,t[rs].val);
		t[root].val1=max(t[ls].val1,t[rs].val1);
	}
	pii query(int x,int y,int root=1,int l=1,int r=n)
	{
//		cout<<x<<" "<<y<<" "<<l<<" "<<r<<" "<<t[root].val.cnt<<" "<<t[root].val.pos<<endl;
		if(l>=x&&r<=y) return t[root].val;
		down(root);
		pii res={0,0};
		if(x<=mid) res=max(res,query(x,y,ls,l,mid));
		if(y>mid) res=max(res,query(x,y,rs,mid+1,r));
		return res;
	}
}using namespace Shiroha;
struct que
{
	int l,r,id;
	bool operator<(const que &a)const{return r<a.r;}
}q[500005];
int ans[500005],pre[500005];
int main()
{
	freopen("destory.in","r",stdin);
	freopen("destory.out","w",stdout);
	read(n,k,m);
	for(int i=1;i<=n;i++) f[i]=i;
	for(int i=1;i<=k;i++)
	{
		int u,v;read(u,v);
		if(find(u)!=find(v)) f[find(u)]=find(v);
	}
//	for(int i=1;i<=n;i++) cout<<find(i)<<" ";cout<<endl;
	for(int i=1;i<=m;i++) read(q[i].l,q[i].r),q[i].id=i;
//	cout<<q[6].l<<" "<<q[6].r<<endl;
//	swap(q[1],q[6]);q[1].id=1;m=1;
	sort(q+1,q+m+1);
//	for(int i=1;i<=n;i++) if(find(i)==84) cout<<i<<endl;
//	for(int i=1;i<=n;i++) cout<<find(i)<<" ";cout<<endl;
	bld();
	for(int i=1,j=1;i<=n;i++)
	{
		int c=find(i);
		add(pre[c]+1,i,i);pre[c]=i;
//		if(i==50) cout<<query(13,13).len<<" "<<query(8,8).len<<endl;
//		cout<<pre[c]+1<<" "<<i<<endl;
		
//		if(i==84)cout<<query(q[j].l,q[j].r).pos<<endl;
//		if(i==94) cout<<i<<" "<<query(8,9).len<<"fuck"<<endl;
//		for(int j=1;j<=n;j++) cout<<query(j,j).len<<" ";cout<<endl;
		while(j<=m&&q[j].r<=i) ans[q[j].id]=-query(q[j].l,q[j].r).se,++j;
	}
	for(int i=1;i<=m;i++) write(ans[i]),putch('\n');
	flush();
	return 0;
}
/*
5 2 5
2 2
4 1
1 1
1 1
2 5
4 5
3 5

5 1 1
4 1
2 5
*/
